<template>
  <div class="generator-view">
    <div class="page-header">
      <h1 class="page-title">应用生成</h1>
      <p class="page-description">通过 AI 智能生成您需要的应用，快速构建原型</p>
    </div>
    
    <div class="generator-content">
      <a-row :gutter="[24, 24]">
        <a-col :xs="24" :lg="12">
          <a-card title="快速生成" class="generator-card">
            <template #extra>
              <a-tag color="blue">推荐</a-tag>
            </template>
            <p class="card-description">
              描述您的需求，AI 将为您生成完整的应用代码
            </p>
            <a-form layout="vertical" class="generator-form">
              <a-form-item label="应用描述">
                <a-textarea 
                  v-model:value="appDescription"
                  placeholder="请描述您想要生成的应用功能和特点..."
                  :rows="4"
                  show-count
                  :maxlength="500"
                />
              </a-form-item>
              <a-form-item label="应用类型">
                <a-select v-model:value="appType" placeholder="选择应用类型">
                  <a-select-option value="web">Web 应用</a-select-option>
                  <a-select-option value="mobile">移动应用</a-select-option>
                  <a-select-option value="desktop">桌面应用</a-select-option>
                  <a-select-option value="api">API 服务</a-select-option>
                </a-select>
              </a-form-item>
              <a-form-item>
                <a-button type="primary" size="large" block @click="generateApp">
                  <template #icon>
                    <ThunderboltOutlined />
                  </template>
                  开始生成
                </a-button>
              </a-form-item>
            </a-form>
          </a-card>
        </a-col>
        
        <a-col :xs="24" :lg="12">
          <a-card title="模板选择" class="generator-card">
            <p class="card-description">
              从预设模板开始，快速创建常见类型的应用
            </p>
            <div class="template-grid">
              <div 
                v-for="template in templates" 
                :key="template.id"
                class="template-item"
                @click="selectTemplate(template)"
              >
                <div class="template-icon">
                  <component :is="template.icon" />
                </div>
                <h4 class="template-title">{{ template.name }}</h4>
                <p class="template-desc">{{ template.description }}</p>
              </div>
            </div>
          </a-card>
        </a-col>
      </a-row>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { 
  ThunderboltOutlined, 
  AppstoreOutlined, 
  MobileOutlined, 
  DesktopOutlined,
  ApiOutlined 
} from '@ant-design/icons-vue'

// 表单数据
const appDescription = ref('')
const appType = ref('')

// 模板数据
const templates = ref([
  {
    id: 1,
    name: '博客系统',
    description: '个人博客网站',
    icon: AppstoreOutlined
  },
  {
    id: 2,
    name: '电商平台',
    description: '在线购物网站',
    icon: MobileOutlined
  },
  {
    id: 3,
    name: '管理后台',
    description: '数据管理系统',
    icon: DesktopOutlined
  },
  {
    id: 4,
    name: 'API 服务',
    description: 'RESTful API',
    icon: ApiOutlined
  }
])

// 生成应用
const generateApp = () => {
  console.log('生成应用:', { appDescription: appDescription.value, appType: appType.value })
  // 这里实现应用生成逻辑
}

// 选择模板
const selectTemplate = (template: any) => {
  console.log('选择模板:', template)
  // 这里实现模板选择逻辑
}
</script>

<style scoped>
.generator-view {
  padding: 0;
}

.page-header {
  text-align: center;
  margin-bottom: 32px;
  padding: 24px 0;
  background: linear-gradient(135deg, #f0f8ff 0%, #e6f4ff 100%);
  border-radius: 8px;
  margin: -32px -24px 32px -24px;
  padding: 48px 24px;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  color: #1677ff;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #1677ff 0%, #69b1ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-description {
  font-size: 16px;
  color: #666;
  margin: 0;
}

.generator-content {
  max-width: 1200px;
  margin: 0 auto;
}

.generator-card {
  height: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.generator-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.card-description {
  color: #666;
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.6;
}

.generator-form {
  margin-top: 16px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.template-item {
  padding: 20px;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #fafafa;
}

.template-item:hover {
  border-color: #1677ff;
  background: #f0f8ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(22, 119, 255, 0.1);
}

.template-icon {
  font-size: 32px;
  color: #1677ff;
  margin-bottom: 12px;
}

.template-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.template-desc {
  font-size: 12px;
  color: #999;
  margin: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    margin: -20px -12px 24px -12px;
    padding: 32px 16px;
  }
  
  .page-title {
    font-size: 24px;
  }
  
  .page-description {
    font-size: 14px;
  }
  
  .template-grid {
    grid-template-columns: 1fr;
  }
}
</style>
